package com.voicechat.firstmet.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;

import com.voicechat.firstmet.R;
import com.voicechat.firstmet.base.BaseAdapter;
import com.voicechat.firstmet.bean.ReportBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @ProjectName: FirstMet
 * @Package: com.voicechat.firstmet.adapter
 * @ClassName: ReportAdapter
 * @Description: java类作用描述
 * @Author: ljp
 * @CreateDate: 2018/10/15 14:57
 * @Version: 1.0
 */
public class ReportAdapter extends BaseAdapter<ReportBean> {
    private SetCheck setCheck;

    public void setSetCheck(SetCheck setCheck) {
        this.setCheck = setCheck;
    }

    /**
     * @param context activity_imessage
     * @param tlist   集合
     * @param mLayout 主布局
     */
    public ReportAdapter(Context context, List<ReportBean> tlist, int mLayout) {
        super(context, tlist, mLayout);
    }



    @Override
    protected RecyclerView.ViewHolder getHeaderViewHolder(View view) {
        return null;
    }

    @Override
    protected RecyclerView.ViewHolder getItemViewHolder(View view) {
        return new ViewHolder(view);
    }

    @Override
    protected RecyclerView.ViewHolder getFooterViewHolder(View view) {
        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
        if (viewHolder instanceof ViewHolder){
            ((ViewHolder) viewHolder).tvTitle.setText(tlist.get(position).getTitle());
            ((ViewHolder) viewHolder).radioButton.setChecked(tlist.get(position).isChecked());
            ((ViewHolder) viewHolder).linearLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    setCheck.setChecked(position,((ViewHolder) viewHolder).radioButton);
                }
            });
        }

    }


    class ViewHolder extends BaseViewHolder{

        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.radio_button)
        RadioButton radioButton;
        @BindView(R.id.linear_radio)
        LinearLayout linearLayout;
        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
    public interface SetCheck{
        void setChecked(int position,View view);
    }
}
